use cp_mpce_demon_rcfs


global hcovars "female_hoh any_seced medication_hh hospitalised_hh any_unhealthy std_asset14_w" 
global dcovars "unemp_w ag_w mfg_w construction_w trade_w wage_worker_w cw_w agw_w public_ent_w non_ag_self_w lfp_w high_educ_w rural_hh_w pct_sc_st_w muslim_w dbranch_pc_w dsh_rural_branch_w dsh_dist_dep_amt16_w dnfs_atmcount_pc_w dpos_terminalcount_pc_w"
global eventcov "distcc_t0 distcc_pt1 distcc_pt2 distcc_pt3 distcc_pt4 distcc_nt2 distcc_nt3 distcc_nt4 distcc_nt5"


global rural_het "pdst_dist_cc_p50 pdlt_dist_cc_p50 pdst_rural_hh pdlt_rural_hh pdst_rural_dist_cc pdlt_rural_dist_cc"
global informal_het "pdst_dist_cc_p50 pdlt_dist_cc_p50 pdst_pre_informal pdlt_pre_informal pdst_pre_informal_dist_cc pdlt_pre_informal_dist_cc"

global seced_het "pdst_dist_cc_p50 pdlt_dist_cc_p50 pdst_pre_seced pdlt_pre_seced pdst_pre_seced_dist_cc pdlt_pre_seced_dist_cc"
global wc_het "pdst_dist_cc_p50 pdlt_dist_cc_p50 pdst_pre_wc pdlt_pre_wc pdst_pre_wc_dist_cc pdlt_pre_wc_dist_cc"

global lic_het "pdst_dist_cc_p50 pdlt_dist_cc_p50 pdst_pre_lic pdlt_pre_lic pdst_any_lic_dist_cc pdlt_any_lic_dist_cc"
global pf_het "pdst_dist_cc_p50 pdlt_dist_cc_p50 pdst_pre_pf pdlt_pre_pf pdst_any_pf_dist_cc pdlt_any_pf_dist_cc"

global branch_het "pdst_dist_cc_p50 pdlt_dist_cc_p50 pdst_dhbranch pdlt_dhbranch pdst_dhbranch_dist_cc pdlt_dhbranch_dist_cc"
global pos_het "pdst_dist_cc_p50 pdlt_dist_cc_p50 pdst_dhpos pdlt_dhpos pdst_dhpos_dist_cc pdlt_dhpos_dist_cc"
global atm_het "pdst_dist_cc_p50 pdlt_dist_cc_p50 pdst_dhatm pdlt_dhatm pdst_dhatm_dist_cc pdlt_dhatm_dist_cc"

global network_het "pdst_dist_cc_p50 pdlt_dist_cc_p50 pdst_std_network2 pdlt_std_network2 pdst_std_network2_dist_cc pdlt_std_network2_dist_cc"
global aware_het "pdst_dist_cc_p50 pdlt_dist_cc_p50 pdst_std_aware pdlt_std_aware pdst_std_aware_dist_cc pdlt_std_aware_dist_cc"


*Table 5: Cash Supply Shock and Household Credit Card Adoption
global coefint "pdst_dist_cc_p50 pdlt_dist_cc_p50 pdst_any_lic_dist_cc pdlt_any_lic_dist_cc pdst_any_pf_dist_cc pdlt_any_pf_dist_cc pdst_std_network2_dist_cc pdlt_std_network2_dist_cc  pdst_dhbranch_dist_cc pdlt_dhbranch_dist_cc pdst_dhpos_dist_cc pdlt_dhpos_dist_cc pdst_dhatm_dist_cc pdlt_dhatm_dist_cc"

eststo clear
eststo: quietly reghdfe any_cc pdst_dist_cc_p50 pdlt_dist_cc_p50 [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum any_cc if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe any_cc pdst_dist_cc_p50 pdlt_dist_cc_p50 $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum any_cc if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe any_cc $lic_het $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum any_cc if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe any_cc $pf_het $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum any_cc if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe any_cc $network_het $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum any_cc if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe any_cc $branch_het $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum any_cc if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe any_cc $pos_het $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum any_cc if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe any_cc $atm_het $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum any_cc if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

esttab, ar2 se(3) b(3)  star(* 0.10 ** 0.05 *** 0.01) keep($coefint) /// 
	nonotes fragment label mtitles("\shortstack{Pr(Credit Card = 1)}" "\shortstack{Pr(Credit Card = 1)}" "\shortstack{Pr(Credit Card = 1)}" "\shortstack{Pr(Credit Card = 1)}" "\shortstack{Pr(Credit Card = 1)}" "\shortstack{Pr(Credit Card = 1)}" "\shortstack{Pr(Credit Card = 1)}" "\shortstack{Pr(Credit Card = 1)}") ///
	order($coefint)
	
*Appendix Table C1: Cash Supply Shock and Household Investments

global coefint "pdst_dist_cc_p50 pdlt_dist_cc_p50"

eststo clear
eststo: quietly reghdfe rf_invest pdst_dist_cc_p50 pdlt_dist_cc_p50 $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum rf_invest if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe risky_invest pdst_dist_cc_p50 pdlt_dist_cc_p50 $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum risky_invest if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe any_fin_invest pdst_dist_cc_p50 pdlt_dist_cc_p50 $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum any_fin_invest if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe mult_fin_invest pdst_dist_cc_p50 pdlt_dist_cc_p50 $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum mult_fin_invest if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe agg_phy_invest pdst_dist_cc_p50 pdlt_dist_cc_p50 $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum agg_phy_invest if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe any_durable_purchase pdst_dist_cc_p50 pdlt_dist_cc_p50 $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum any_durable_purchase if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe any_borrow pdst_dist_cc_p50 pdlt_dist_cc_p50 $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum any_borrow if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe any_borrow_b pdst_dist_cc_p50 pdlt_dist_cc_p50 $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum any_borrow_b if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe any_borrow_if pdst_dist_cc_p50 pdlt_dist_cc_p50 $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum any_borrow_if if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

esttab, ar2 se(3) b(3)  star(* 0.10 ** 0.05 *** 0.01) keep($coefint) /// 
	nonotes fragment label mtitles("\shortstack{Risk-Free\\Asset}" "\shortstack{Risky\\Asset}" "\shortstack{Financial\\Asset}" "\shortstack{Mulitiple\Financial\\Asset}" "\shortstack{Gold\\Real Estate}" "\shortstack{Household Durables}" "\shortstack{Any\\Borrowing}" "\shortstack{Any\\Formal\\Borrowing}" "\shortstack{Any\\Informal\\Borrowing}") ///
	order($coefint)

*Appendix Table C2: Cash Supply Shock and Household Consumption
global coefint "pdst_dist_cc_p50 pdlt_dist_cc_p50"

eststo clear
eststo: quietly reghdfe ln_mpce pdst_dist_cc_p50 pdlt_dist_cc_p50 [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum mpce if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe ln_mpce pdst_dist_cc_p50 pdlt_dist_cc_p50 $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum mpce if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe ln_essential_exp_pc pdst_dist_cc_p50 pdlt_dist_cc_p50 [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum essential_exp_pc if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe ln_essential_exp_pc pdst_dist_cc_p50 pdlt_dist_cc_p50 $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum essential_exp_pc if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe ln_luxury_exp_pc pdst_dist_cc_p50 pdlt_dist_cc_p50 [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum luxury_exp_pc if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe ln_luxury_exp_pc pdst_dist_cc_p50 pdlt_dist_cc_p50 $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum luxury_exp_pc if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

esttab, ar2 se(3) b(3)  star(* 0.10 ** 0.05 *** 0.01) keep($coefint) /// 
	nonotes fragment label mtitles("\shortstack{Per Capita\\Consumption\\(Log)}" "\shortstack{Per Capita\\Consumption\\(Log)}" "\shortstack{Per Capita\\Essential\\Consumption\\(Log)}" "\shortstack{Per Capita\\Essential\\Consumption\\(Log)}" "\shortstack{Per Capita\\Luxury\\Consumption\\(Log)}" "\shortstack{Per Capita\\Luxury\\Consumption\\(Log)}") ///
	order($coefint)

*Appendix Table D4: Cash Supply Shock and Household Consumption, Heterogeneity by Household Characteristics
global coefint "pdst_dist_cc_p50 pdlt_dist_cc_p50 pdst_rural_dist_cc pdlt_rural_dist_cc pdst_pre_informal_dist_cc pdlt_pre_informal_dist_cc pdst_pre_wc_dist_cc pdlt_pre_wc_dist_cc pdst_any_lic_dist_cc pdlt_any_lic_dist_cc pdst_any_pf_dist_cc pdlt_any_pf_dist_cc"	
	
eststo clear
eststo: quietly reghdfe ln_mpce $rural_het $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum mpce if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe ln_mpce $informal_het $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum mpce if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe ln_mpce $wc_het $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum mpce if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe ln_mpce $lic_het $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum mpce if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

eststo: quietly reghdfe ln_mpce $pf_het $hcovars $dcovars [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
quietly sum mpce if wave <= 8 [aw = weight]
scalar avg = r(mean)
estadd scalar avg

esttab, ar2 se(3) b(3)  star(* 0.10 ** 0.05 *** 0.01) keep($coefint) /// 
	nonotes fragment label mtitles("\shortstack{Per Capita\\Consumption\\(Log)}" "\shortstack{Per Capita\\Consumption\\(Log)}" "\shortstack{Per Capita\\Consumption\\(Log)}" "\shortstack{Per Capita\\Consumption\\(Log)}" "\shortstack{Per Capita\\Consumption\\(Log)}") ///
	order($coefint)
	
*Figure 7: Cash Supply Shock and Household Credit Card Adoption, Event Study Plot
quietly reghdfe any_cc $eventcov [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
parmest, level(95) label list(parm label estimate min* max* p) saving("cp_demon_any_cc_event", replace)

*Figure C1: Cash Supply Shock and Household Consumption, Event Study Plot
quietly reghdfe ln_mpce $eventcov [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
parmest, level(95) label list(parm label estimate min* max* p) saving("cp_demon_mpce_event", replace)

*Figure C1: Cash Supply Shock and Household Food Consumption, Event Study Plot
quietly reghdfe ln_food_exp_pc $eventcov [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
parmest, level(95) label list(parm label estimate min* max* p) saving("cp_demon_food_exp_event", replace)

*Figure C1: Cash Supply Shock and Luxury Expenditure, Event Study Plot
quietly reghdfe ln_luxury_exp_pc $eventcov [aw = weight], absorb(HHID stwave) cluster(distcd) tolerance(0.00001) maxiterations(100000)
parmest, level(95) label list(parm label estimate min* max* p) saving("cp_demon_luxury_exp_event", replace)


*Figure 7: Cash Supply Shock and Household Credit Card Adoption, Event Study Plot
clear all
use cp_demon_any_cc_event

set obs `= _N + 1'
replace parm = "nt1" if parm == ""
replace label = "t = 0" if strpos(parm, "t0")
replace label = "-1" if parm == "nt1"

foreach var of varlist estimate stderr min95 max95 { 
replace `var' = 0 if `var' == .
}

replace label = "0" if label == "t = 0"
destring label, force replace 
drop if label == .
sort label

twoway (connected estimate label, graphregion(color(white)) lc(navy) mc(navy)) ///
(rline min95 max95 label, lpattern(dot) lcolor(blue)), yline(0, lcolor(red)) ///
xline(-1, lcolor(solid) lpattern(dash)) xlabel(-4 0 4) ///
xtitle("") ytitle("Percent", height(5)) legend(off) ///
ylab(#3, nogrid) xlab(, nogrid) graphregion(margin(2 2 2 2)) subtitle("Any Credit Card")

*Figure C1: Cash Supply Shock and Household Consumption, Event Study Plot

clear all
use cp_demon_mpce_event

set obs `= _N + 1'
replace parm = "nt1" if parm == ""
replace label = "t = 0" if strpos(parm, "t0")
replace label = "-1" if parm == "nt1"

foreach var of varlist estimate stderr min95 max95 { 
replace `var' = 0 if `var' == .
}

replace label = "0" if label == "t = 0"
destring label, force replace 
drop if label == .
sort label

twoway (connected estimate label, graphregion(color(white)) lc(navy) mc(navy)) ///
(rline min95 max95 label, lpattern(dot) lcolor(blue)), yline(0, lcolor(red)) ///
xline(-1, lcolor(solid) lpattern(dash)) xlabel(-4 0 4) ///
xtitle("") ytitle("Percent", height(5)) legend(off) ///
ylab(#3, nogrid) xlab(, nogrid) graphregion(margin(2 2 2 2)) subtitle("Consumption")

*Figure C1: Cash Supply Shock and Household Food Consumption, Event Study Plot
clear all
use cp_demon_food_exp_event

set obs `= _N + 1'
replace parm = "nt1" if parm == ""
replace label = "t = 0" if strpos(parm, "t0")
replace label = "-1" if parm == "nt1"

foreach var of varlist estimate stderr min95 max95 { 
replace `var' = 0 if `var' == .
}

replace label = "0" if label == "t = 0"
destring label, force replace 
drop if label == .
sort label

twoway (connected estimate label, graphregion(color(white)) lc(navy) mc(navy)) ///
(rline min95 max95 label, lpattern(dot) lcolor(blue)), yline(0, lcolor(red)) ///
xline(-1, lcolor(solid) lpattern(dash)) xlabel(-4 0 4) ///
xtitle("") ytitle("Percent", height(5)) legend(off) ///
ylab(#3, nogrid) xlab(, nogrid) graphregion(margin(2 2 2 2)) subtitle("Food Expenditures")

*Figure C1: Cash Supply Shock and Luxury Expenditure, Event Study Plot
clear all
use cp_demon_luxury_exp_event

set obs `= _N + 1'
replace parm = "nt1" if parm == ""
replace label = "t = 0" if strpos(parm, "t0")
replace label = "-1" if parm == "nt1"

foreach var of varlist estimate stderr min95 max95 { 
replace `var' = 0 if `var' == .
}

replace label = "0" if label == "t = 0"
destring label, force replace 
drop if label == .
sort label

twoway (connected estimate label, graphregion(color(white)) lc(navy) mc(navy)) ///
(rline min95 max95 label, lpattern(dot) lcolor(blue)), yline(0, lcolor(red)) ///
xline(-1, lcolor(solid) lpattern(dash)) xlabel(-4 0 4) ///
xtitle("") ytitle("Percent", height(5)) legend(off) ///
ylab(#3, nogrid) xlab(, nogrid) graphregion(margin(2 2 2 2)) subtitle("Luxury Expenditures")


